<template>
  <div ref="container">
    <breadcrumb :breadList="breadList" :name="name">
      <div class="handle-box" slot="handleContent">
      </div>
    </breadcrumb>
    <a-card>
      <a-form @submit="handleSubmit" :form="form">
        <a-row clss="form-row" :gutter="16">
          <a-col :lg="8" :md="12" :sm="24">
            <a-form-item label="项目编号" :labelCol="{lg: {span: 8}, sm: {span: 7}}" :wrapperCol="{lg: {span: 14}, sm: {span: 17} }">
              <a-input v-model="queryParam.proCode" placeholder="项目编号"/>
            </a-form-item>
          </a-col>
          <a-col :lg="8" :md="12" :sm="24">
            <a-form-item label="项目名称" :labelCol="{lg: {span: 8}, sm: {span: 7}}" :wrapperCol="{lg: {span: 14}, sm: {span: 17} }">
              <a-textarea v-model="queryParam.proName" rows="1" placeholder="项目名称"/>
            </a-form-item>
          </a-col>
          <a-col :lg="2" :md="12" :sm="24">
            <a-form-item label="" :colon="false">
              <a-button class="common-btn" @click="toSearch('2')">查询</a-button>
            </a-form-item>
          </a-col>
          <a-col :lg="2" :md="12" :sm="24">
            <a-form-item label="" :colon="false">
              <a-button class="common-btn" @click="$refs.advSearchModel.add('')">高级搜索</a-button>
            </a-form-item>
          </a-col>
        </a-row>
        <adv-search-model ref="advSearchModel" @closeModel="closeModel"></adv-search-model>
      </a-form>
    </a-card>
    <a-card>
      <a-table
        :columns="columns"
        :dataSource="loadData"
        bordered
        :loading="loading"
        :pagination="false"
        :scroll="{ x: 1800 }">
        <template slot="operation" slot-scope="text, record">
          <p style="display:inline" @click="toApprove('approve',record)">
            <a href="javascript:;">审批</a>
          </p>
        </template>
      </a-table>
    </a-card>
  </div>
</template>

<script>
import Breadcrumb from '@/components/tools/Breadcrumb'
import AdvSearchModel from './advSearchModel'
// import { getSupplierList } from '@/api/mockdata'
export default {
  name: 'SupplierManagementList',
  components: {
    Breadcrumb,
    AdvSearchModel
  },
  data () {
    return {
      name: '',
      breadList: [],
      loading: false,
      form: this.$form.createForm(this),
      // 查询参数
      queryParam: {},
      // 表头
      columns: [
        {
          title: '项目编号',
          width: '6%',
          dataIndex: 'proCode'
        }, {
          title: '项目名称',
          width: '8%',
          dataIndex: 'proName'
        }, {
          title: '责任单位',
          width: '8%',
          dataIndex: 'dutyCompany'
        }, {
          title: '联系人',
          width: '6%',
          dataIndex: 'proPerson'
        }, {
          title: '联系电话',
          width: '8%',
          dataIndex: 'proTel'
        },
        {
          title: '总用户数',
          width: '8%',
          dataIndex: 'totalCount'
        },
        {
          title: '总建筑面积',
          width: '8%',
          dataIndex: 'totalEara'
        },
        {
          title: '改造路径',
          width: '8%',
          dataIndex: 'proType'
        },
        {
          title: '开工时间',
          width: '8%',
          dataIndex: 'proStart'
        },
        {
          title: '完工时间',
          width: '8%',
          dataIndex: 'proEnd'
        },
        {
          title: '项目完工进度',
          width: '8%',
          dataIndex: 'proPlan'
        },
        {
          title: '发起变更时间',
          width: '8%',
          dataIndex: 'updateTime'
        },
        {
          title: '操作',
          dataIndex: 'operation',
          scopedSlots: { customRender: 'operation' }
        }
      ],
      // 加载数据方法 必须为 Promise 对象
      loadData: []
    }
  },
  created () {
    this.loading = true
    this.getBreadCrumb()
    setTimeout(() => {
      this.getData('1')
    }, 1000)
  },
  methods: {
    // 面包屑处理
    getBreadCrumb () {
      this.breadList = []
      this.name = this.$route.name
      this.$route.matched.forEach(item => {
        console.log('1111', item)
        this.breadList.push(item)
      })
    },
    getData (code) {
      const data = [
        {
          proCode: 'SX_TY_001',
          proName: '世界500强',
          dutyCompany: '大中国',
          proPerson: '王老五',
          proTel: '18899999999',
          totalCount: '999999999',
          totalEara: '100000',
          proType: '煤改电',
          proStart: '2015-12-30',
          proEnd: '2019-01-01',
          proPlan: '100%',
          totalCountEquipment: '123455555',
          remark: '人，要么庸俗，要么孤独',
          updateTime: '2020-02-02'
        }, {
          proCode: 'SX_TY_002',
          proName: '世界500强',
          dutyCompany: '大中国',
          proPerson: '王老五',
          proTel: '18899999999',
          totalCount: '999999999',
          totalEara: '100000',
          proType: '煤改电',
          proStart: '2015-12-30',
          proEnd: '2019-01-01',
          proPlan: '100%',
          totalCountEquipment: '55555555',
          remark: '越美丽的东西我越不可碰',
          updateTime: '2020-02-02'
        }, {
          proCode: 'SX_TY_003',
          proName: '世界500强',
          dutyCompany: '大中国',
          proPerson: '王老五',
          proTel: '18899999999',
          totalCount: '999999999',
          totalEara: '100000',
          proType: '煤改电',
          proStart: '2015-12-30',
          proEnd: '2019-01-01',
          proPlan: '100%',
          totalCountEquipment: '111111',
          remark: '是否你也会在人潮拥挤的街头,寻寻觅觅,期盼相遇在夕阳斜斜的乌衣巷口',
          updateTime: '2020-02-02'
        }, {
          proCode: 'SX_TY_004',
          proName: '世界500强',
          dutyCompany: '大中国',
          proPerson: '王老五',
          proTel: '18899999999',
          totalCount: '999999999',
          totalEara: '100000',
          proType: '煤改电',
          proStart: '2015-12-30',
          proEnd: '2019-01-01',
          proPlan: '100%',
          totalCountEquipment: '2222222',
          remark: '过去了就是昨天,新的一页翻开还是晴朗的天',
          updateTime: '2020-02-02'
        }, {
          proCode: 'SX_TY_005',
          proName: '世界500强',
          dutyCompany: '大中国',
          proPerson: '王老五',
          proTel: '18899999999',
          totalCount: '999999999',
          totalEara: '100000',
          proType: '煤改电',
          proStart: '2015-12-30',
          proEnd: '2019-01-01',
          proPlan: '100%',
          totalCountEquipment: '12222125',
          remark: '希望的灯一旦熄灭,生活刹那间变成了一片黑暗',
          updateTime: '2020-02-02'
        }, {
          proCode: 'SX_TY_006',
          proName: '世界500强',
          dutyCompany: '大中国',
          proPerson: '王老五',
          proTel: '18899999999',
          totalCount: '999999999',
          totalEara: '100000',
          proType: '煤改电',
          proStart: '2015-12-30',
          proEnd: '2019-01-01',
          proPlan: '100%',
          totalCountEquipment: '66666666',
          remark: '人生的起起落落间,总会有一些情怀需要安静回味',
          updateTime: '2020-02-02'
        }
      ]
      if (code === '1') {
        this.loadData = data
        setTimeout(() => {
          this.loading = false
        }, 1000)
      } else {
        this.loadData = data
        setTimeout(() => {
          this.loading = false
          this.$success({
            title: '查询成功'
          })
        }, 1000)
      }
    },
    toSearch (status) {
      this.loading = true
      this.getData(status)
    },
    handleSubmit () {
      console.log('ttt')
    },
    closeModel () {
      this.getData('2')
    },
    toApprove (type, record) {
      console.log('审批', type)
      this.$router.push({
        name: 'addProjects',
        query: {
          type: type,
          proDetails: JSON.stringify(record)
        }
      })
    }
  }
}

</script>

<style lang="less" scoped>
// .handle-box {
//   display: flex;
//   margin-bottom: 10px;
//   margin-left: 800px;
// }
// .handle-btn {
//   margin-left:5px;
// }
</style>
